//
//  HomeView.m
//  汽车大灯色温蓝牙
//
//  Created by dfwx on 2020/9/5.
//  Copyright © 2020 zhongdaodianzi. All rights reserved.
//

#import "HomeView.h"

@interface HomeView () <CustomSliderViewDelegate, HomeCircleViewDelegate>

@end

@implementation HomeView



- (void)awakeFromNib {
    
    [super awakeFromNib];
    
    if (!self.sliderView) {
        self.sliderView = [[CustomSliderView alloc]init];
        self.sliderView.delegate = self;
        [self.sliderContentView addSubview:self.sliderView ];
    }
    
//    self.sliderView.backgroundColor = [UIColor whiteColor];
    
    [self.sliderView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.top.mas_equalTo(0);
    }];
    
    self.circleView = [[HomeCircleView alloc]init];
    self.circleView.delegate = self;
    [self.circleContentView insertSubview:self.circleView belowSubview:self.topRightButton];
    
    [self.circleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.top.mas_equalTo(0);
    }];
    
    self.weatherNameLabel.font = [UIFont fontWithName:@"FZXiHei I-Z08S" size:15];
    self.autoButton.titleLabel.font = [UIFont fontWithName:@"FZXiHei I-Z08S" size:17];



    
}



- (void)layoutSubviews {
    self.circleView.hidden = NO;
    
}

#pragma mark - action

- (IBAction)closeButtonAction:(UIButton *)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(HomeViewCloseLightAction)]) {
        [self.delegate HomeViewCloseLightAction];
    }
}


- (IBAction)leftTopButtonClicked:(UIButton *)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(HomeViewTopLeftButtonClicked)]) {
        [self.delegate HomeViewTopLeftButtonClicked];
    }
}

- (IBAction)rightTopButtonClicked:(UIButton *)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(HomeViewTopRightButtonClicked)]) {
        [self.delegate HomeViewTopRightButtonClicked];
    }
}

- (IBAction)allWhiteButtonClicked:(UIButton *)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(HomeViewModelButtonClicked:)]) {
        [self.delegate HomeViewModelButtonClicked:0];
    }
}

- (IBAction)fiftyWYButtonClicked:(UIButton *)sender {
    [self.delegate HomeViewModelButtonClicked:1];
}

- (IBAction)allYellowButtonClicked:(UIButton *)sender {
    [self.delegate HomeViewModelButtonClicked:2];
}

- (IBAction)customWriteButtonClicked:(UIButton *)sender {
    [self.delegate HomeViewModelButtonClicked:3];
}

- (IBAction)allLightButtonClicked:(UIButton *)sender {
    [self.delegate HomeViewModelButtonClicked:4];
}

- (IBAction)autoButtonClicked:(UIButton *)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(HomeViewAutoButtonClicked)]) {
        [self.delegate HomeViewAutoButtonClicked];
    }
}


#pragma mark - delegate

- (void)customSliderViewSliderAction:(CGFloat)value {

    NSLog(@"亮度:%f",value);
    if (self.delegate && [self.delegate respondsToSelector:@selector(HomeViewSlderViewAction:)]) {
        [self.delegate HomeViewSlderViewAction:value];
    }
}

- (void)customSliderViewSliderMoveAction:(CGFloat)value {

    if (self.delegate && [self.delegate respondsToSelector:@selector(HomeViewSlderViewMoveAction:)]) {
        [self.delegate HomeViewCircleMoveAction:value];
    }
}

- (void)HomeCircleViewCircleClickedActionWith:(CGFloat)value {

    NSLog(@"白黄数值:%f",value);
    if (self.delegate && [self.delegate respondsToSelector:@selector(HomeViewCircleAction:)]) {
        [self.delegate HomeViewCircleAction:value];
    }
}

- (void)HomeCircleViewCircleMoveActionWith:(CGFloat)value {

    if (self.delegate && [self.delegate respondsToSelector:@selector(HomeViewCircleMoveAction:)]) {
        [self.delegate HomeViewCircleMoveAction:value];
    }
}

- (void)HomeCircleViewCircleStartActionWith:(CGFloat)value {
    
    self.fourButton.selected = YES;
}

- (void)customSliderViewSliderStartAction:(CGFloat)value {
    
    self.fourButton.selected = YES;
}

- (void)HomeCircleViewCircleEndLearnActionWith:(CGFloat)value {
    
//    self.fourButton.selected = NO;

}


- (void)customSliderViewSliderEndLearnAction:(CGFloat)value {
    
//    self.fourButton.selected = NO;

}



@end
